package pwd.allen.job;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * @author 门那粒沙
 * @create 2020-05-31 18:14
 **/
@Slf4j
public class MyJob implements Job {

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("触发比计划差的毫秒数：{}", context.getFireTime().getTime() - context.getScheduledFireTime().getTime());
        log.info("【MyJob】jobDataMap[{}]：{}", context.getMergedJobDataMap().hashCode(), JSON.toJSONString(context.getMergedJobDataMap()));
    }

    public void setName(String name) {
        System.out.println("如果jobDataMap有key为name的属性，quartz会自动调用本set方法：" + name);
    }
}
